<?php

	// site owner
	$to = "marcus.moeller@gmx.ch";
	$subject = "Anmeldung: Freie Software Fotobuch";

	// contact form fields
	$vorname = trim( $_POST['vorname'] );
	$nachname = trim( $_POST['nachname'] );
	$email = trim( $_POST['email'] );
	$nachricht = trim( $_POST['nachricht'] );
	

	// check for error
	$error = false;
	
	if ( $vorname === "" )
	{
		$error = true;
	}
	if ( $nachname === "" )
	{
		$error = true;
	}
	elseif ( $email === "" )
	{
		$error = true;
	}
	elseif ( $nachricht === "" )
	{
		$error = true;
	}
	// end check for error
	
	// no error send mail
	if ( !$error )
	{
		
		$body = "Vorname: $vorname \n\nNachname: $nachname \n\nEmail: $email \n\nNachricht: $nachricht";
		
		$headers = 'From: ' . $name . ' <' . $email . '> ' . "\r\n" . 'Reply-To: ' . $email;
		
		mail( $to, $subject, $body, $headers );
		
		echo 'success';
		
	}
	else
	{
		echo 'error';
	}
	// end no error send mail

	
?>
